/**
 * 第1阶段 模块1 题1
 */

package stage1.module1;

import java.util.ArrayList;
import java.util.Random;

public class Q1 {

    public static void main(String[] args) {

        // setup program constants
        // the lower bound
        final int LOWER = 1;
        // upper bound for red ball
        final int RED_UPPER = 33;
        // upper bound for blue ball
        final int BLUE_UPPER = 16;

        Random rand = new Random();

        // number of red balls
        int numReds = 6;

        ArrayList<Integer> reds = new ArrayList<>();
        for (int i = 0; i < numReds; i++) {
            int temp = rand.nextInt(RED_UPPER) + LOWER;
            while(reds.contains(temp)) {
                // duplicate number generated, get a new one
                temp = rand.nextInt(RED_UPPER) + LOWER;
            }
            reds.add(temp);
        }
        int blue = rand.nextInt(BLUE_UPPER) + LOWER;

        // out
        System.out.println("The red balls are:");
        for (int i = 0; i < numReds; i++) {
            System.out.print(reds.get(i) + " ");
        }
        // start a new line
        System.out.println("\n");
        System.out.println("The blue ball is:");
        System.out.println(blue);
    };
}
